
import 'package:flutter_bsbdj/utils/constant.dart';
import 'package:flutter/material.dart';

class ThemeEvent<T extends State> {

  List<T> _list=[];

  static ThemeEvent _themeEvent;

  static ThemeEvent getInstance(){
    if(_themeEvent==null){
      _themeEvent=ThemeEvent();
    }
    return _themeEvent;
  }

  void registerEvent(T t){
    _list.add(t);
  }

  void changeTheme(){
    Constant.getInstance().changeTheme();
    for(var t in _list){
      // ignore: invalid_use_of_protected_member
      t.setState((){});
    }
  }

  void unregister(T t){
    _list.remove(t);
  }

}